﻿using System;
using System.Collections.Generic;
using CTS.Com.Domain.Constants;
using CTS.Com.Domain.Helper;

namespace CTS.Com.Domain.Model
{
    [Serializable]
    public class BasicResponse : ViewModelBase
    {
        public IList<Message> Messages { get; set; }
        public bool HasMessage { get { return Messages.Count > 0; } }
        public bool ResultFlag { get; set; }
        public string Status { get; set; }
        public string CallType { get; set; }

        public BasicResponse()
        {
            Messages = new List<Message>();
        }

        public void AddMessage(Message message)
        {
            Messages.Add(message);
        }

        public void AddMessage(string messageId, params object[] param)
        {
            Messages.Add(MessageHelper.GetMessage(messageId, param));
        }

        public Message MessageSingle
        {
            get { return Messages.Count > 0 ? Messages[0] : null; }
        }

        public bool IsAdd { get { return Status == Logics.CD_STATUS_ADD; } }
        public bool IsEdit { get { return Status == Logics.CD_STATUS_EDIT; } }
        public bool IsInit { get { return CallType == Logics.CD_CALLTYPE_INIT; } }
        public bool IsCopy { get { return CallType == Logics.CD_CALLTYPE_COPY; } }

        public bool IsAddInit { get { return IsAdd && IsInit; } }
        public bool IsAddCopy { get { return IsAdd && IsCopy; } }
        public bool IsEditInit { get { return IsEdit && IsInit; } }
    }
}
